Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Objects /
Chapter 1 - Introduction to QuickDraw GX / Objects and Memory


Application Memory and QuickDraw GX Memory

When you program with QuickDraw GX, you are concerned with at least two separate memory heaps: the application heap, which holds your code and data structures, and a part of QuickDraw GX memory called the graphics client heap, which holds the objects you create with Quickdraw GX. As an application, you allocate variables and execute in application memory. You can directly access any data structures in that heap. Much of Macintosh system software, including the toolbox, can affect the application heap, sometimes in unwanted ways (as during memory compaction).

QuickDraw GX rarely uses the application heap (except for storing printing-related objects). It allocates its objects, structures, and variables in the graphics client heap. QuickDraw GX memory is private; you cannot directly access the contents of the graphics client heap except under special conditions. The graphics client heap does not even have to be in the same physical address space as the application heap. For example, QuickDraw GX can execute from and store objects in the memory on a graphics accelerator card.

QuickDraw GX objects are private because they are in private memory. That means you must make QuickDraw GX calls to access objects and their information, but it also means that you can make almost any call without worrying that it might move application memory.

Typically, your application manages its own structures in the application heap, and makes function calls to obtain or change the contents of the graphics client heap. For example when you call a GXGetObjectProperty function, QuickDraw GX places a copy
of the contents of an object's property in your application's heap. If you modify the information, you can then call a GXSetObjectProperty function to copy the new values from your application's heap back into the object in the graphics client heap.

If you are a Macintosh programmer, remember that QuickDraw GX memory is completely separate, and you needn't be concerned about its location or contents. Macintosh Memory Manager functions cannot allocate, resize, or determine the size of any QuickDraw GX object. To manage its memory, QuickDraw GX has its own internal memory manager and memory management functions. See the memory management chapter of Inside Macintosh: QuickDraw GX Environment and Utilities for more information. See Inside Macintosh: Memory for information on the Macintosh Memory Manager.

The QuickDraw GX memory manager may move objects, unload them to disk if necessary, and reload them when they are needed again. To reference and use an object, you needn't be concerned with or even know whether it is in a loaded or unloaded state. QuickDraw GX automatically loads any unloaded object when it is needed, even if that means unloading another object to make room. See "Automatic Loading and Unloading of Objects" on page 1-21 for more information.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996